﻿<Window x:Class="CapstoneProjectAEReader.GUIs.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Height="auto" Width="auto" Closed="WindowClosedHandler" WindowState="Maximized"
        Title="Academic Ebook Reader" Icon="pack://application:,,,/AEIcon.ico"
        DataContext="{Binding RelativeSource={RelativeSource Self}}">
    <Window.Resources>
        
        <SolidColorBrush x:Key="OnChose" Color="LightCyan"/>

        <SolidColorBrush x:Key="SolidBorderBrush" Color="#888" />

        <SolidColorBrush x:Key="NotChose" Color="LightBlue" />

        <SolidColorBrush x:Key="DisabledBackgroundBrush" Color="#EEE" />

        <SolidColorBrush x:Key="DisabledBorderBrush" Color="#AAA" />

        <SolidColorBrush x:Key="DisabledForegroundBrush" Color="#888" />

        <Style TargetType="{x:Type TabItem}">
            <Setter Property="Height" Value="20" />
            <Setter Property="Width" Value="140" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TabItem}">
                        <Grid>
                            <Border Name="Border" Margin="0,0,-4,0" 
                                    Background="{StaticResource NotChose}" BorderBrush="{StaticResource SolidBorderBrush}" 
                                    BorderThickness="1,1,1,1" CornerRadius="2,12,0,0" >
                                <ContentPresenter x:Name="ContentSite"
                                                  VerticalAlignment="Center"
                                                  HorizontalAlignment="Center"
                                                  ContentSource="Header"
                                                  Margin="12,2,12,2"
                                                  RecognizesAccessKey="True"/>
                            </Border>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter Property="Panel.ZIndex" Value="100" />
                                <Setter TargetName="Border" Property="Background" Value="{StaticResource OnChose}" />
                                <Setter TargetName="Border" Property="BorderThickness" Value="1,1,1,0" />
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter TargetName="Border" Property="Background" Value="{StaticResource DisabledBackgroundBrush}" />
                                <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource DisabledBorderBrush}" />
                                <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>

    <Grid Name="Host">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="80*"/>
            <ColumnDefinition Width="371*"/>
            <ColumnDefinition Width="285*"/>
            <ColumnDefinition Width="24*"/>
        </Grid.ColumnDefinitions>
        <DockPanel Background="LightSkyBlue" Grid.ColumnSpan="4">
            <!--<Border BorderBrush="LightBlue" BorderThickness="2" DockPanel.Dock="Top">
                <Grid>
                    <Menu Background="LightSkyBlue" HorizontalAlignment="Left" VerticalAlignment="Center" >
                        <MenuItem x:Name="generalTab" Header="General" Margin="0,0,0,0" Height="26" Width="100"  
                                      BorderBrush="LightBlue" BorderThickness="0,0,2,0">
                            <MenuItem x:Name="btOpenFile" InputGestureText="Ctrl + O" Click="OpenFileHandler" >
                                <MenuItem.Icon>
                                    <Image Source="Images/Document.png" Stretch="Fill" Height="16" Width="16"/>
                                </MenuItem.Icon>
                            </MenuItem>
                            <MenuItem x:Name="btImport" InputGestureText="Ctrl + I" Click="ImportHandler" >
                                <MenuItem.Icon>
                                    <Image Source="Images/Import.png" Stretch="Fill" Height="16" Width="16"/>
                                </MenuItem.Icon>
                            </MenuItem>
                            <Separator />
                            <MenuItem x:Name="EBookTab" Click="OpenEBookTab" />
                            <MenuItem x:Name="NoteTab" Click="OpenNoteTab" />
                            <MenuItem x:Name="SettingTab" Click="OpenSettingTab" />
                            <Separator />
                            <MenuItem x:Name="btExit"/>
                        </MenuItem>
                    </Menu>
                </Grid>
            </Border>--> 
            <Border BorderBrush="LightCyan" BorderThickness="3,0,3,0" DockPanel.Dock="Bottom">
                <Label x:Name="txtStatus" HorizontalAlignment="Right"/>
            </Border>

            <Grid x:Name="gridtable" Height="Auto" Width="Auto">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="75*"/>
                    <ColumnDefinition Width="231*"/>
                    <ColumnDefinition Width="74*"/>
                </Grid.ColumnDefinitions>
                <Grid.Background>
                    <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                        <GradientStop Color="Azure" Offset="0" />
                        <GradientStop Color="LightCyan" Offset="0.5" />
                        <GradientStop Color="Azure" Offset="1" />
                    </LinearGradientBrush>
                </Grid.Background>

                <TabControl IsSynchronizedWithCurrentItem="True"  Margin="3,0,3,0" Name="tabDynamic" SelectionChanged="HandleChangeTabItem" Grid.ColumnSpan="3" >
                    <TabControl.Template>
                        <ControlTemplate TargetType="TabControl">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="auto"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="*"/>
                                </Grid.RowDefinitions>
                                <Menu HorizontalAlignment="Center" VerticalAlignment="Center" 
                                      Grid.Column="0" Grid.Row="0">
                                    <Menu.Resources>
                                        <Style x:Key="MenuItemStyle" TargetType="{x:Type MenuItem}">
                                            <Style.Triggers>
                                                <Trigger Property="IsEnabled" Value="True">
                                                    <Setter Property="Background" Value="Green"/>
                                                    <Setter Property="Header" Value="Enabled"/>
                                                    <Setter Property="HeaderTemplate">
                                                        <Setter.Value>
                                                            <DataTemplate>
                                                                <Image Source="Images/AEReaderOff.png" Stretch="Fill" Margin="-6,0,0,0"/>
                                                            </DataTemplate>
                                                        </Setter.Value>
                                                    </Setter>
                                                </Trigger>
                                                <Trigger Property="IsMouseOver" Value="True">
                                                    <Setter Property="Background" Value="Black"/>
                                                    <Setter Property="Header" Value="MouseOver"/>
                                                    <Setter Property="HeaderTemplate">
                                                        <Setter.Value>
                                                            <DataTemplate>
                                                                <Image Source="Images/AEReader.png" Stretch="Fill" Margin="-6,0,0,0"/>
                                                            </DataTemplate>
                                                        </Setter.Value>
                                                    </Setter>
                                                </Trigger>
                                                <Trigger Property="IsKeyboardFocusWithin" Value="true">
                                                    <Setter Property="Background" Value="Red"/>
                                                    <Setter Property="Header" Value="Focus"/>
                                                    <Setter Property="HeaderTemplate">
                                                        <Setter.Value>
                                                            <DataTemplate>
                                                                <Image Source="Images/AEReaderChose.png" Stretch="Fill" Margin="-6,0,0,0"/>
                                                            </DataTemplate>
                                                        </Setter.Value>
                                                    </Setter>
                                                </Trigger>
                                            </Style.Triggers>
                                        </Style>
                                    </Menu.Resources>
                                    <MenuItem x:Name="AEReaderTab" Height="29" Width="104" BorderBrush="LightBlue"
                                              BorderThickness="2" Style="{StaticResource MenuItemStyle}">
                                        <MenuItem x:Name="btOpenFile" Header="{Binding HeaderClass.OpenString}" InputGestureText="Ctrl + O" Click="OpenFileHandler" >
                                            <MenuItem.Icon>
                                                <Image Source="Images/Document.png" Stretch="Fill" Height="16" Width="16"/>
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <MenuItem x:Name="btImport" Header="{Binding HeaderClass.ImportString}" InputGestureText="Ctrl + I" Click="ImportHandler" >
                                            <MenuItem.Icon>
                                                <Image Source="Images/Import.png" Stretch="Fill" Height="16" Width="16"/>
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <Separator />
                                        <MenuItem x:Name="EBookTab" Header="{Binding HeaderClass.EBookString}" Click="OpenEBookTab">
                                            <MenuItem.Icon>
                                                <Image Source="Images/Library_Alt.png" Stretch="Fill" Height="16" Width="16"/>
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <MenuItem x:Name="NoteTab" Header="{Binding HeaderClass.NoteString}" Click="OpenNoteTab">
                                            <MenuItem.Icon>
                                                <Image Source="Images/Note_Alt.png" Stretch="Fill" Height="16" Width="16"/>
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <MenuItem x:Name="SettingTab" Header="{Binding HeaderClass.SettingString}" Click="OpenSettingTab" >
                                            <MenuItem.Icon>
                                                <Image Source="Images/Setting_Alt.png" Stretch="Fill" Height="16" Width="16"/>
                                            </MenuItem.Icon>
                                        </MenuItem>
                                        <Separator />
                                        <MenuItem x:Name="btExit" Header="{Binding HeaderClass.ExitString}" Click="btExit_Click" >
                                            <MenuItem.Icon>
                                                <Image Source="Images/Exit.png" Stretch="Fill" Height="16" Width="16"/>
                                            </MenuItem.Icon>
                                        </MenuItem>
                                    </MenuItem>
                                </Menu>
                                
                                <DockPanel IsItemsHost="True" LastChildFill="False" Margin="2,2,2,0"  Grid.Column="1" Grid.Row="0"/>

                                <Border BorderThickness="0" BorderBrush="LightCyan" Grid.Row="1" Grid.ColumnSpan="2">
                                    <Border BorderThickness="{TemplateBinding BorderThickness}" 
                                            BorderBrush="{TemplateBinding BorderBrush}">
                                        <Border Background="{TemplateBinding Background}">
                                            <ContentPresenter ContentSource="SelectedContent"/>
                                        </Border>
                                    </Border>
                                </Border>
                            </Grid>
                        </ControlTemplate>
                    </TabControl.Template>

                    <TabControl.Resources>
                        <Style x:Key="TabItemText" TargetType="{x:Type TextBlock}">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=TabItem}}" Value="True">
                                    <Setter Property="Foreground" Value="ForestGreen"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=TabItem}}" Value="False">
                                    <Setter Property="Foreground" Value="Black"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>

                        <DataTemplate x:Key="TabHeader" DataType="TabItem">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock x:Name="abc" Text="{Binding RelativeSource={RelativeSource AncestorType=TabItem }, Path=Header}" 
                                           TextWrapping="Wrap" Width="95" TextTrimming="CharacterEllipsis" Style="{StaticResource TabItemText}"/>
                                <Button Name="btnDelete" Margin="5,0,0,0" Padding="0" Click="BtnDeleteClick" Background="Transparent" BorderThickness="0"
                                        HorizontalAlignment="Right" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}}, Path=Name}">
                                    <Image Source="Close.png" Height="14" Width="14"/>
                                </Button>
                            </StackPanel>
                        </DataTemplate>
                    </TabControl.Resources>
                    
                    <!--TabItem>
                        <TabItem.Header>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="EBook Management" Margin="4,0,0,0" VerticalAlignment="Center" Style="{StaticResource TabItemText}"
                                           TextWrapping="Wrap" Width="95" TextTrimming="CharacterEllipsis"/>
                                <Button Name="btnDelete" Margin="5,0,0,0" Padding="0" Click="BtnDeleteClick" 
                                        CommandParameter="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}}, Path=Name}">
                                    <Image Source="Images/Delete.gif" Height="11" Width="11"></Image>
                                </Button>
                            </StackPanel>
                        </TabItem.Header>
                        <ScrollViewer>
                            <getLibGUI:LocalLibrary />
                        </ScrollViewer>
                    </TabItem-->
                    
                </TabControl>
            </Grid>
        </DockPanel>
    </Grid>
</Window>
